// @ts-ignore
import config from "@/utils/config";
import { request } from "./request";
const api = {

    // ------------------------ 用户登录 ----------------
    checkCode: () => {
        return request<{ captcha: string, uuid: string }>({
            url: '/captchaImage',
            method: 'get',
        })
    },
    userLogin: (data: { password: string; name: string; code: string }) => {
        return request({
            data,
            url: '/atUser/pcLogin',
            method: 'post',
        })
    },
    userPhoneLogin: (data: { phone: string; noteCode: string; }) => {
        return request({
            data,
            url: '/atFrontUser/phoneLogin',
            method: 'post',
        })
    },
    getLoginCode: (data: { phone:string }) => {
        return request({
            data,
            url: '/atFrontUser/sendNoteCode',
            method: 'post',
        })
    },
    // ------------------------ 用户注册 ----------------
    userRegister: (data: any) => {
        return request({
            data,
            url: '/atFrontUser/accountRegister',
            method: 'post',
        })
    },
    brokerRegister: (data: any) => {
        return request({
            data,
            url: '/atFrontUser/applyForArtBroker',
            method: 'put',
        })
    },
    editUserInfo: (data: any) => {
        return request({
            data,
            url: '/atFrontUser/updatePersonageInfo',
            method: 'put',
        })
    },
    // ------------------------ 图片上传 ----------------
    uploadImage: (data: any) => {
        const params: any = {
            data,
            url: '/file/uploadImage',
            method: 'post',
        }
        if (process.env.NODE_ENV === 'development') {
            params.baseURL = 'https://zyykjcgzhxt.cdutcm.edu.cn/api/'
        }
        return request(params)
    },
    // ------------------------ 获取配置 ----------------
    getSetting: (type: string) => {
        return request({
            params: { type },
            url: '/atPcAcademy/findAcademy',
            method: 'get',
        })
    },

    getBrokerList: (params: any) => {
        return request({
            params,
            url: `/atPcUser/findTechnologyBroker`,
            method: 'get',
        })
    },

    getDemandList: (data: any) => {
        return request({
            data,
            url: `/atFrontDemand/findDemandList`,
            method: 'post',
        })
    },
    getActList: (data: any) => {
        return request({
            data,
            url: `/atFrontAchievement/findAchievementList`,
            method: 'post',
        })
    },
    addAch: (data: any) => {
        return request({
            data,
            url: `/atFrontDemand/deliverScheme`,
            method: 'post',
        })
    },
    addAchNew: (data: any) => {
        return request({
            data,
            url: `/atAchievement/addAchievement`,
            method: 'post',
        })
    },
    getMyActList: () => {
        return request({
            url: `/atFrontAchievement/findMyAchievement`,
            method: 'get',
        })
    },
    getMyDemand: () => {
        return request({
            url: `/atFrontDemand/findMyDemand`,
            method: 'get',
        })
    },
    addDemand: (data: any) => {
        return request({
            data,
            url: `/atFrontDemand/abutmentDemand`,
            method: 'post',
        })
    },
    addDemandNew: (data: any) => {
        return request({
            data,
            url: `/atDemand/addDemand`,
            method: 'post',
        })
    },
    findResourceAbutment: (params: any) => {
        return request({
            params,
            url: `/atFrontResourceAbutment/findResourceAbutment`,
            method: 'get',
        })
    },
    findTalentPoolMessage: (data: any) => {
        return request({
            data,
            url: `/atFrontUser/findTalentPoolMessage`,
            method: 'post',
        })
    },

    getAnnList: (params: any) => {
        return request({
            params,
            url: `/atFrontAchievementDemand/findAchievementPublicity`,
            method: 'get',
        })
    },
    getBannerList: (params: any) => {
        return request({
            params,
            url: `/atFrontBanner/findBanner`,
            method: 'get',
        })
    },
    getRecommendList: (params?: any) => {
        return request({
            params,
            url: `/atAchievement/recommendAchievement`,
            method: 'get',
        })
    },
    getAccRecommendList: (params?: any) => {
        return request({
            params,
            url: `/atDemand/recommendDemand`,
            method: 'get',
        })
    },
    findAchievementNum: (params?: any) => {
        return request({
            params,
            url: `/atFrontAchievement/findAchievementNum`,
            method: 'get',
        })
    },
    exportTemplate: (params: any, callback: any) => {
        return request({
            params,
            url: `/atFrontAchievementDemand/exportTemplate`,
            method: 'get',
            responseType: 'blob'
        }, callback)
    },
    findAchievement: () => {
        return request({
            url: '/atAchievementTransition/findAchievement',
            method: 'get',
        })
    },
    findBigScreenData: (params?: any) => {
        return request({
            params,
            url: `/atAchievementTransition/findBigScreenData`,
            method: 'get',
        })
    },

    chatStream: (params: any,callback) => {
        const data: any = {
            params,
            url: '/chat/chatStream',
            method: 'get',
        }

        data.baseURL = config.myAiUrl

        return request(data,callback)
    },
}
export default api
